<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			div{
				height: 200px; 
				width: 200px;
				border: 1px solid red;
			}
			#d2{
				height: 400px;
				border: 2px solid black;
			}
		</style>
		<script>
			function showDiv()
			{
				 var d=document.getElementById("d2");
				//var h=document.defaultView.getComputedStyle(d,null).height;
				//兼容ie老版本
				 var h=(document.defaultView.getComputedStyle(d,null)||d.currentStyle).height;
				 alert("高度是"+h);//可以获得实际的高度
			}
			function incDiv(){
				var d=document.getElementById("d2");
				var h=(document.defaultView.getComputedStyle(d,null)||d.currentStyle).height;
				d.style.height=(parseInt(h)+10)+"px";
			}
		</script>
	</head>
	<body>
		<div id="d2">
			
		</div>
		<input type="button" value="获得div高度" onclick="showDiv()"/>
		<input type="button" value="给div加高10个像素" onclick="incDiv()"/>
	</body>
</html>
